package com.dxtan90.util;

import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.List;

/**
 * @author shijunhao
 * @since 2024/4/17 14:19
 */
public class InterfaceScanner {
    public static List<Class<?>> findClassesImplementingInterface(String packageName, Class<?> interfaceClass) throws ClassNotFoundException {
        List<Class<?>> implementingClasses = new ArrayList<>();
        List<Class<?>> classes = ClassFinder.findClasses(packageName);

        for (Class<?> clazz : classes) {
            if (interfaceClass.isAssignableFrom(clazz) && !Modifier.isAbstract(clazz.getModifiers())) {
                implementingClasses.add(clazz);
            }
        }
        return implementingClasses;
    }
}
